package com.example.moderndashboard.Activity;

// NewActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.moderndashboard.R;

import java.util.ArrayList;
import java.util.List;

public class NewActivity extends AppCompatActivity {

    private ListView listView;
    private List<String> weatherList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new);

        listView = findViewById(R.id.listView);
        weatherList = new ArrayList<>();

        Intent intent = getIntent();
        WeatherResponse weatherResponse = (WeatherResponse) intent.getSerializableExtra(WeatherActivity.EXTRA_WEATHER_DATA);

        if (weatherResponse != null) {
            List<FutureWeather> futureWeatherList = weatherResponse.getResult().getFuture();
            if (futureWeatherList != null) {
                for (FutureWeather futureWeather : futureWeatherList) {
                    String weatherInfo = futureWeather.getDate() + ": " + futureWeather.getWeather() + " " + futureWeather.getTemperature();
                    weatherList.add(weatherInfo);
                }

                ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, weatherList);
                listView.setAdapter(adapter);
            }
        } else {
            Log.e("NewActivity", "No WeatherResponse data found");
        }
    }
}
